package com.example.elasticsearchhelpersample.repository.entity.condition;

import java.util.Objects;
import org.pippi.elasticsearch.helper.core.beans.annotation.query.mapping.extend.RangeParam;
import org.pippi.elasticsearch.helper.core.handler.EsConditionHandle;

/**
 * AgeUseCondition
 *
 * @author JohenTeng
 * @date 2021/12/9
 */
public class UserConditions {

    public static class AgeUserCondition implements EsConditionHandle<RangeParam> {

        @Override
        public boolean test(RangeParam val) {
            if (Objects.isNull(val)) {
                return false;
            }
            Object left = val.getLeft();
            if (Objects.nonNull(left)) {
                int leftVal = (int) left;
                if (leftVal >= 20) {
                    return true;
                }
            }
            return false;
        }
    }

}



